Skip to content

Main task for module5.#13

Merged
Fentezi3 merged 9 commits intomainfrom
module5
Nov 26, 2020
Merged

Main task for module5.#13
Fentezi3 merged 9 commits intomainfrom
module5

Conversation

@Fentezi3
Copy link
Copy Markdown
Owner

No description provided.

@Fentezi3 Fentezi3 requested a review from dKatechev November 15, 2020 11:50
.gitignore Outdated
.idea/
Java.iml No newline at end of file
Java.iml
module5/module5.iml No newline at end of file
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use wildcards for .iml files instead of hardcoded values.


private static void validateFacultyGroupStudentsSubjectIsEmpty(List<Faculty> facultyList) throws MyException {
if (facultyList.isEmpty()) {
throw new EmptyFacultyListException("You haven't faculty in university.");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no faculties in university instead of You haven't ...

}
for (Faculty faculty : facultyList) {
if (faculty.getGroups().isEmpty()) {
throw new EmptyFacultyGroupsException("You haven't group in " + faculty.getFacultyName() + " faculty");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no...

}
for (Group group : faculty.getGroups()) {
if (group.getStudentsList().isEmpty()) {
throw new EmptyStudentListException("You haven't students in " + group.getGroupName() + " group.");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no...

for (Group group : faculty.getGroups()) {
for (Student students : group.getStudentsList()) {
if (students.getSubjects().containsKey(enteredSubject)) {
sum += students.getSubjects().get(enteredSubject);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You call student.getSubjects() two times.
Create variable for this before if block.

"group, for " + subjectName + " is - " + average);
}

private static void averageGradeForOneSubjectInUniversity(List<Faculty> facultyList, String enteredSubject) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enteredSubject?

@@ -0,0 +1,4 @@
package bean;

public abstract class MyException extends Exception {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create constructor:

protected MyException(String message) {
    super(message);
}

@@ -0,0 +1,4 @@
package bean;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move all exceptions to separate package

package bean;

public class EmptySubjectException extends MyException {
private final String studentName;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to use this field.
Just create constructor:

    public EmptySubjectException(String message) {
        super(message);
    }

Here and in other custom messages.

/**
* Validation what this data is not null.
*
* @param facultyList all faculty in university.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all faculties...

}
for (Faculty faculty : facultyList) {
if (faculty.getGroups().isEmpty()) {
throw new EmptyFacultyGroupsException("There is no group in " + faculty.getName() + " faculty");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, There are no groups...

}
for (Group group : faculty.getGroups()) {
if (group.getStudentList().isEmpty()) {
throw new EmptyStudentListException("There is no students in " + group.getName() + " group.");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, There are no students...

}
for (Student students : group.getStudentList()) {
if (students.getSubjects().isEmpty()) {
throw new EmptySubjectException("There is " + students.getName() + " no subjects");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, There is a student ... with no subjects
or Student ... has no subjects

package exceptions;

public class EmptyStudentListException extends MyException {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redundant empty line

package exceptions;

public class EmptyFacultyGroupsException extends MyException {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redundant empty line


@Override
public String toString() {
return "Students{" +
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Student{...

System.out.println();
calculateAverageGradeForOneSubjectInUniversity(facultyList, "Math");
} catch (MyException e) {
e.getStackTrace();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this catch block log error message?

List<Faculty> emptyFacultyList = emptyFacultyList();
List<Faculty> facultyWithoutGroup = facultyWithoutGroup();
List<Faculty> groupWithoutStudents = groupWithoutStudents();
List<Faculty> studentWithoutSubjects = studentWithoutSubjects();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now please create List of Lists and do in for loop the next:

  • validate each list
  • calculate each list's average values (all three methods should be called)

@Fentezi3 Fentezi3 merged commit 12fcc2f into main Nov 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants